package com.education.expenses.web.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * User: Alex Kasianik
 * Date: 09.08.12
 * Time: 10:11
 */
@Controller
public class LoginController {
    @RequestMapping("/login_success")
    public String redirectAfterLogin(HttpServletRequest request) {
        if (request.isUserInRole("USER_ROLE")) {
            return "redirect:/user";
        }
        if (request.isUserInRole("ADMIN_ROLE")) {
            return "redirect:/admin";
        }
        if (request.isUserInRole("APPROVER_ROLE")) {
            return "redirect:/approver";
        }
        return "redirect:/home";
    }
}
